package com.echo.register.commons.config;

import org.springframework.boot.web.servlet.server.Session;

public class SessionCache {
    /**
     * 利用线程本地变量来保存登录信息
     *
     * @author Horace
     */

    private static ThreadLocal<Session> threadLocal = new ThreadLocal<>();

    public static <T extends Session> void put(T t) {
        threadLocal.set(t);
    }

    @SuppressWarnings("unchecked")
    public static <T> T get() {
        return (T) threadLocal.get();
    }

    public static void remove() {
        threadLocal.remove();
    }


}
